package com.shop.cereshop.admin.controller.feedback;

import com.shop.cereshop.admin.annotation.NoRepeatSubmit;
import com.shop.cereshop.admin.annotation.NoRepeatWebLog;
import com.shop.cereshop.admin.page.feedback.FeedbackVO;
import com.shop.cereshop.admin.param.feedback.GetFeedbackDTO;
import com.shop.cereshop.admin.param.feedback.ProcessFeedbackDTO;
import com.shop.cereshop.admin.service.feedback.FeedbackService;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.feedback.Feedback;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description: TODO
 * @author lx
 * @date 2025/10/26 10:34
 * @version 1.0
 */

@RestController
@RequestMapping("/feedback")
@Api(value = "FeedbackController")
@RequiredArgsConstructor
public class FeedbackController {

  private final FeedbackService feedbackService;

  @GetMapping("/list")
  @ApiOperation(value = "获取用户反馈列表接口")
  public Result<Page<FeedbackVO>> getList(@ModelAttribute GetFeedbackDTO param) throws CoBusinessException {
    Page<FeedbackVO> result = feedbackService.getList(param);
    return Result.success(result);
  }

  @GetMapping("/detail")
  @ApiOperation(value = "获取用户反馈详情接口")
  public Result<FeedbackVO> getDetail(
      @RequestParam(value = "feedbackId") @ApiParam(value = "反馈ID", required = true) Long feedbackId,
      @RequestParam(value = "userType") @ApiParam(value = "用户类型(0-普通用户,1-商家,2-业务员，3-代理商，4-股东，5-匿名人员)", required = true) Integer userType)
      throws CoBusinessException {
    FeedbackVO result = feedbackService.getDetail(feedbackId, userType);
    return Result.success(result);
  }

  @PostMapping("/process")
  @ApiOperation(value = "处理用户反馈接口")
  @NoRepeatSubmit
  @NoRepeatWebLog
  public Result<String> processFeedback(@RequestBody ProcessFeedbackDTO param) throws CoBusinessException {
    feedbackService.processFeedback(param);
    return Result.success();
  }
}
